/**
 * @file task_gsensor.c
 * @brief 
 * @author  Harvey.Huang
 * @version 1.0
 * @date 2024-09-24
 * 
 * @copyright Copyright (C) 2019 Queclink Wireless Solutions (ShenZhen) Co., Ltd. All Rights Reserved.
 * 
 * @par 修改日志:
 * <table>
 * <tr><th>Date       <th>Version <th>Author  <th>Description
 * <tr><td>2024-09-24 <td>1.0     <td>     <td>内容
 * </table>
 */
#include "global.h"
#include "cmsis_os2.h"
#include "bsp.h"
#include "gsensor/gsensor.h"
#include "FreeRTOS.h"
#include "task.h"

#define LOG_TAG TAG_SNSR
#include "elog.h"



static TaskHandle_t snsr_handle;


void task_snsr_init(void);
void task_snsr_entry(void *param);
void task_snsr_process(void);
void task_snsr_deinit(void);

extern int32_t bsp_gsensor_init(void);




/// @brief Mmgr功能入口函数
/// @param  
/// @return 
int32_t qltask_sensor_start(void)
{
    /* 1. sensor硬件初始化 */
    bsp_gsensor_init();      

    /* 2. Create sensor Thread with routine function snsr_routine; */
    if(pdPASS != xTaskCreate(task_snsr_entry, "sensor", TASKSTACK_SENSOR, NULL, TASKPRI_SENSOR, &snsr_handle))
    {
        return -1;
    }

    return 0; 
}


#include "bsp_gsensor.h"
#include "sensor/skeleton/sensor_support_chip.h"
#include <qlcommon.h>


/// @brief snsr初始化
/// @param  
void task_snsr_init(void)
{
    //等待Gsensor上电完全
    vTaskDelay(_MS2TICKS(1000));
	
	swei_gsensor_module_init();
}

/// @brief snsr处理流程
/// @param  
void task_snsr_process(void)
{  
    swei_proc_gsensor_info_handler();
}


/// @brief snsr 处理线程
/// @param  
void task_snsr_entry(void *param)
{
    log_i("task_snsr run.\r\n");
    task_snsr_init();

    while(1)
    {
        task_snsr_process();
    }
}


/// @brief snsr去初始化
/// @param  
void task_snsr_deinit(void)
{       
    
}


